package com.dodo.blog.request;

import com.dodo.blog.ui.component.repeater.OrderDirection;

import java.util.ArrayList;
import java.util.List;

/**
 * @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
 */
public class BasicRequest
{
    private int firstRow;

    private int maxRows;

    private List<Sort> sortList = new ArrayList<Sort>();

    public BasicRequest()
    {
        this( -1, -1 );
    }

    public BasicRequest( int firstRow, int maxRows )
    {
        this.firstRow = firstRow;
        this.maxRows = maxRows;
    }

    public int getFirstRow()
    {
        return firstRow;
    }

    public int getMaxRows()
    {
        return maxRows;
    }

    public List<Sort> getSortList()
    {
        return sortList;
    }

    public void addSort( String orderBy, OrderDirection orderDirection )
    {
        sortList.add( new Sort( orderBy, orderDirection ) );
    }

    public class Sort
    {

        private String orderBy;

        private OrderDirection orderDirection;

        public Sort( String orderBy, OrderDirection orderDirection )
        {
            this.orderBy = orderBy;
            this.orderDirection = orderDirection;
        }

        public String getOrderBy()
        {
            return orderBy;
        }

        public OrderDirection getOrderDirection()
        {
            return orderDirection;
        }
    }
}
